<?php

declare(strict_types = 1);

/**
 * WeEngine System
 *
 * (c) We7Team 2021 <https://www.w7.cc>
 *
 * This is not a free software
 * Using it under the license terms
 * visited https://www.w7.cc for more details
 */

namespace app\validate;

use think\Validate;

class News extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'          => ['require', 'number'],
        'title'       => ['chsDash'],
        'label'       => ['chsDash'],
        'description' => ['chsDash'],
        'content'     => ['chsDash'],
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [];
    
    protected $scene = [
        'delete' => ['id'],
        'detail' => ['id'],
    ];
    
    public function sceneEdit()
    {
        return $this->only(['id'])
            ->remove('id', 'require');
    }
    
    public function sceneSave()
    {
        return $this->only(['id', 'title', 'label', 'description', 'content'])
            ->remove('id', 'require');
    }
}
